const path = require("path");
let HtmlWebpackPlugin = require("html-webpack-plugin");
const { VueLoaderPlugin } = require("vue-loader");
let webpack = require("webpack");
__webpack_base_uri__ = "http://localhost:8081";
let config = {
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          "style-loader", // 将 JS 字符串生成为 style 节点
          "css-loader", // 将 CSS 转化成 CommonJS 模块
          "sass-loader", // 将 Sass 编译成 CSS，默认使用 Node Sass
        ],
      },
      {
        test: /\.scss$/,
        use: [
          "style-loader", // 将 JS 字符串生成为 style 节点
          "css-loader", // 将 CSS 转化成 CommonJS 模块
          "sass-loader", // 将 Sass 编译成 CSS，默认使用 Node Sass
        ],
      },
      {
        test: /\.(png|jpg|gif|jpeg)$/,
        use: [
          {
            loader: "file-loader",
            options: {},
          },
        ],
      },
      {
        test: /\.vue$/,
        loader: "vue-loader",
      },
    ],
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: "./src/index.html",
      filename: "index.html",
      favicon: path.resolve('favicon.ico'),
      minify: {
        removeAttributeQuotes: true,
        collapseWhitespace: true,
      },
    }),
    new VueLoaderPlugin(),
    new webpack.ProvidePlugin({
      process: "process/browser",
    }),
  ],
  mode: "none",
  entry: {
    main: path.join(__dirname, "./src/main.js"),
  },
  output: {
    filename: "[name].bundle.js",
    path: path.join(__dirname, "./dist"),
  },
};

module.exports = config;
